<template>
    <div style="margin-top: 60px;margin-left:40px;border: 0px solid red;" >
        <el-form style="margin-left: -40px" :model="ruleForm"  ref="ruleForm" label-width="100px" class="demo-ruleForm">
        </el-form>

       <el-table
                :data="tableData"
                border
                stripe
                style="width: 100%;position: relative;top:-30px">
                <el-table-column
                    fixed
                    prop="reid"
                    label="ID"
                    width="40">
              </el-table-column>
            <el-table-column
                    fixed
                    prop="name"
                    label="名称"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="lowEdu"
                    label="最低学历"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="welfare"
                    label="福利"
                    width="100">
            </el-table-column>
             <el-table-column
                    prop="salary"
                    label="薪资"
                    width="110">
            </el-table-column>
            <el-table-column
                    prop="number"
                    label="招聘人数"
                    width="50" >
            </el-table-column>
              <el-table-column
                    prop="contactName"
                    label="联系人姓名"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="contactPhone"
                    label="联系电话"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="place"
                    label="工作地点"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="releaseDate"
                    label="发布时间"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="requirement"
                    label="工作要求"
                    width="150">
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button
                            size="mini"
                            @click="edit(scope.row)">编辑</el-button>
                    <el-button
                            size="mini"
                            type="danger"
                            @click="del(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination style="margin-top: 20px;float: right"
                       background
                       layout="prev, pager, next"
                       :page-size="pageSize"
                       :total="total"
                       :current-page.sync="currentPage"
                       @current-change="page"><!-- 修改当前页面 -->
        </el-pagination>
    </div>

</template>

<script>
    export default {
        data() {
            return {
                companyuser:'',
                tableData:null,
                currentPage: 1,
                pageSize: 2,
                total: 1,//赋一个初始值
                ruleForm: {
                    page: '',
                    size: 5
                },
            }
        },
        methods:{
            page(currentPage){
              const _this = this
            /*   alert(this.currentPage) */
                 axios.get('http://localhost:8182/recruitment/list/'+currentPage+'/'+_this.pageSize+'/'+_this.companyuser.cuid).then(function (resp) {
                        _this.tableData = resp.data.data.data
                        _this.total = resp.data.data.total
                    })
            },
            /* 修改功能 */
            edit(row){
              
                this.$router.push('/updateRecruitment?id='+row.reid)
            },
            /* 删除功能 */
            del(row) {
                const _this = this
                this.$confirm('确认删除【'+row.name+'】吗？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.delete('http://localhost:8182/recruitment/deleteById/'+row.reid).then(function (resp) {
                        if(resp.data.code==0){
                            _this.$alert('【'+row.name+'】已删除', '', {
                                confirmButtonText: '确定',
                                callback: action => {
                                    location.reload()
                                }
                            });
                        }
                    });
                });
            }
        },
        created() {
            const _this = this
              let companyuser = JSON.parse(window.localStorage.getItem('companyuser'))
              this.companyuser = companyuser
             /*  console.log(_this.companyuser.cuid) */
            axios.get('http://localhost:8182/recruitment/list/1/' +_this.pageSize+"/"+_this.companyuser.cuid).then(function (resp) {
                _this.tableData = resp.data.data.data
                 _this.total = resp.data.data.total 
            })
        }
    }
</script>